package com.book.xsp.bookparent.controller;


import com.book.xsp.bookparent.config.R;
import com.book.xsp.bookparent.entity.Student;
import com.book.xsp.bookparent.service.IStudentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author snake_skin
 * @since 2023-11-29
 */
@RestController
@RequestMapping("/student")
@CrossOrigin
@Slf4j
public class StudentController {

    @Resource
    IStudentService iStudentService;

    // 获取所有学生信息
    @GetMapping
    public R getAllStudent() {
        List<Student> studentList = iStudentService.getALlStudent();

        return R.ok().data("list",studentList);
    }

    @GetMapping("{studentNo}")
    public R getStudentByNo(@PathVariable String studentNo) {
        Student student = iStudentService.getStudentByNo(studentNo);
        return R.ok().data("student",student);
    }
}
